import request from '@/utils/request'

// 网关监控API

// 获取系统统计信息
export function getSystemStats() {
  return request({
    url: '/api/monitor/stats',
    method: 'get'
  })
}

// 获取连接设备列表
export function getConnectedDevices() {
  return request({
    url: '/api/monitor/devices',
    method: 'get'
  })
}

// 获取平台客户端列表
export function getPlatformClients() {
  return request({
    url: '/api/monitor/platformClients',
    method: 'get'
  })
}

// 获取最近消息流水
export function getRecentMessages(limit = 50) {
  return request({
    url: '/api/monitor/messages/recent',
    method: 'get',
    params: { limit }
  })
}

// 搜索消息流水
export function searchMessages(query) {
  return request({
    url: '/api/monitor/messages/search',
    method: 'get',
    params: query
  })
}

// 获取设备映射列表
export function listDeviceMap(query) {
  return request({
    url: '/api/iot/deviceMap/list',
    method: 'get',
    params: query
  })
}

// 获取设备映射详情
export function getDeviceMap(id) {
  return request({
    url: '/api/iot/deviceMap/' + id,
    method: 'get'
  })
}

// 新增设备映射
export function addDeviceMap(data) {
  return request({
    url: '/api/iot/deviceMap',
    method: 'post',
    data: data
  })
}

// 修改设备映射
export function updateDeviceMap(data) {
  return request({
    url: '/api/iot/deviceMap',
    method: 'put',
    data: data
  })
}

// 删除设备映射
export function delDeviceMap(id) {
  return request({
    url: '/api/iot/deviceMap/' + id,
    method: 'delete'
  })
}

// 获取主题映射列表
export function listTopicMap(query) {
  return request({
    url: '/api/iot/topicMap/list',
    method: 'get',
    params: query
  })
}

// 新增主题映射
export function addTopicMap(data) {
  return request({
    url: '/api/iot/topicMap',
    method: 'post',
    data: data
  })
}

// 修改主题映射
export function updateTopicMap(data) {
  return request({
    url: '/api/iot/topicMap',
    method: 'put',
    data: data
  })
}

// 删除主题映射
export function delTopicMap(id) {
  return request({
    url: '/api/iot/topicMap/' + id,
    method: 'delete'
  })
}

// 获取属性映射列表
export function listPropertyMap(query) {
  return request({
    url: '/api/iot/propertyMap/list',
    method: 'get',
    params: query
  })
}

// 新增属性映射
export function addPropertyMap(data) {
  return request({
    url: '/api/iot/propertyMap',
    method: 'post',
    data: data
  })
}

// 修改属性映射
export function updatePropertyMap(data) {
  return request({
    url: '/api/iot/propertyMap',
    method: 'put',
    data: data
  })
}

// 删除属性映射
export function delPropertyMap(id) {
  return request({
    url: '/api/iot/propertyMap/' + id,
    method: 'delete'
  })
}
